class InfoLayer {
    constructor() {

    }

    open() {
        layui.use('layer', function () {
            var layer = layui.layer;
            var height = window.innerHeight - 60;
            layer.open({
                id: 'sidelayer',
                title: ' ',
                type: 1,
                content: $("#info-layer"),
                area: ['360px', height + 'px'],
                resize: false,
                maxmin: true,
                shade: 0,
                offset: 'r',
                success: function () {
                    document.getElementById("info-layer").style.display = "block";

                    var galleryThumbs = new Swiper('#gallery-thumbs', {
                        spaceBetween: 10,
                        slidesPerView: 6,
                        freeMode: true,
                        watchSlidesVisibility: true,
                        watchSlidesProgress: true,
                    });

                    var galleryCurousel = new Swiper('#gallery-carousel', {
                        spaceBetween: 10,
                        navigation: {
                            nextEl: '.swiper-button-next',
                            prevEl: '.swiper-button-prev',
                        },
                        thumbs: {
                            swiper: galleryThumbs
                        }
                    });

                    document.getElementById("gallery-back").addEventListener("click", function () {
                        var gallery = document.getElementById("gallery");
                        gallery.classList.remove("gallery-show")
                        gallery.classList.add("gallery-hide");
                    });

                    var galleryImages = document.getElementsByClassName("info-layer-gallery-img");
                    for (var i = 0; i < galleryImages.length; i++) {
                        galleryImages[i].addEventListener("click", function () {
                            //打开全屏图库
                            var gallery = document.getElementById("gallery");
                            gallery.classList.remove("gallery-hide")
                            gallery.classList.add("gallery-show");
                        });
                    }
                },
                full: function () {
                    var tabItems = document.getElementsByClassName("layui-tab-item");
                    for (var i = 0; i < tabItems.length; i++) {
                        tabItems[i].classList.add("layui-tab-item-fullscreen");
                    }

                    var imgItems = document.getElementsByClassName("info-layer-gallery-img");
                    for(var j = 0; j < imgItems.length; j++)
                    {
                        imgItems[j].classList.add("info-layer-gallery-img-fullscreen");
                    }
                },
                restore: function () {
                    var tabItems = document.getElementsByClassName("layui-tab-item");
                    for (var i = 0; i < tabItems.length; i++) {
                        tabItems[i].classList.remove("layui-tab-item-fullscreen");
                    }

                    var imgItems = document.getElementsByClassName("info-layer-gallery-img");
                    for(var j = 0; j < imgItems.length; j++)
                    {
                        imgItems[j].classList.remove("info-layer-gallery-img-fullscreen");
                    }
                },
                min:function(){
                    document.getElementById("info-layer").style.display = none;
                }
            });
        });

        //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
        layui.use('element', function () {
            var element = layui.element;
            //…
        });
    }

    close() {

    }

}